﻿using _01.策略模式.Enums;
using _01.策略模式.Strategies;

namespace _01.策略模式.Factories
{
    /// <summary>
    /// 折扣策略工厂
    /// </summary>
    public static class DiscountFactory
    {
        #region 01.根据客户类型获取折扣策略 —— static IDiscountStrategy GetDiscountStrategy(CustomerType customerType)
        /// <summary>
        /// 根据客户类型获取折扣策略
        /// 适用对象：产品、订单
        /// </summary>
        /// <param name="customerType">客户类型</param>
        /// <returns>折扣策略</returns>
        public static IDiscountStrategy GetDiscountStrategy(CustomerType customerType)
        {
            switch (customerType)
            {
                case CustomerType.Trade:
                    return new TradeDiscountStrategy();
                default:
                    return new NullDiscountSrategy();
            }
        } 
        #endregion

        #region 02.根据订单金额获取折扣策略 —— static IDiscountStrategy GetDiscountStrategy(decimal orderAmount)
        /// <summary>
        /// 根据订单金额获取折扣策略
        /// 适用对象：订单
        /// </summary>
        /// <param name="orderAmount">订单金额</param>
        /// <returns>折扣策略</returns>
        public static IDiscountStrategy GetDiscountStrategy(decimal orderAmount)
        {
            if (orderAmount >= 2000)
            {
                return new LargeOrderDiscountStrategy();
            }
            return new NullDiscountSrategy();
        } 
        #endregion
    }
}
